#include <bits/stdc++.h>
using namespace std;

int T;
int n;
int a[10001];
int color[10001];		//0:red	1:blue
int c[10001];
int ans=0;

void count()
{
	int blue=-1,red=-1,ans0=0;
	for(int i=1;i<=n;i++)
	{
		if(color[i]==0)
		{
			if(red==-1)
			{
				red=i;
				continue;
			}
			else
			{
				if(a[i]==a[red])
					ans0+=a[i];
				red=i;
			}
		}
		else
		{
			if(blue==-1)
			{
				blue=i;
				continue;
			}
			else
			{
				if(a[i]==a[blue])
					ans0+=a[i];
				blue=i;
			}
		}
	}
	ans=max(ans0,ans);
}

void dfs(int step)
{
	if(step>n)
	{
		count();
		return;
	}
	for(int i=0;i<=1;i++)
	{
		color[step]=i;
		dfs(step+1);
	}
}

int main()
{
	freopen("color.in","r",stdin);
	freopen("color.out","w",stdout);
	
	int i,k;
	cin>>T;
	for(k=1;k<=T;k++)
	{
		cin>>n;
		for(i=1;i<=n;i++)
			cin>>a[i];
		dfs(1);
		cout<<ans<<endl;
		ans=0;
	}
	
	return 0;
}

